<?xml version='1.0' encoding='UTF-8' ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
      xmlns:h="http://java.sun.com/jsf/html"
      xmlns:f="http://java.sun.com/jsf/core"
      xmlns:ui="http://java.sun.com/jsf/facelets"
      xmlns:p="http://primefaces.org/ui"
      xmlns:o="http://omnifaces.org/ui"
      xmlns:pe="http://primefaces.org/ui/extensions"
      xmlns:ccFilter="http://xmlns.jcp.org/jsf/composite/compositions/candidateFilters"
      xmlns:ccActualFilter="http://xmlns.jcp.org/jsf/composite/compositions/candidateActualFilters"
      xmlns:ccDetail="http://xmlns.jcp.org/jsf/composite/compositions/candidateDetail">        

    <body>

        <ui:composition template="/WEB-INF/templates/newMainCompanyTemplate.xhtml">
            <f:metadata>
                <o:componentIdParam componentIdName="component" clientIdName="client" />
            </f:metadata>
            <ui:define name="viewBagCommand">
                <p:commandButton disabled="#{empty bagBean.selectedCandidates}" id="recruitButton" ajax="false" value="#{messages.Recruit}" actionListener="#{bagBean.setSearch(newCreateSearchBean.search)}" action="#{bagBean.redirectToSearchBag()}"></p:commandButton>
            </ui:define>
            <ui:define name="companyContent">
                <h:outputScript library="javascript" name="waitImages.js"></h:outputScript>
                <h:outputScript library="javascript" name="newCreateSearch.js"></h:outputScript>
                <h:outputStylesheet library="css" name="company/company.css"></h:outputStylesheet>
                <h:outputStylesheet library="css" name="company/search/search.css"></h:outputStylesheet>
                <h:outputStylesheet library="css" name="company/search/search_desktop.css" media="screen and (min-width:1025px) and (max-width:1600px)"></h:outputStylesheet>
                <h:outputStylesheet library="css" name="company/search/search_desktop_wide.css" media="screen and (min-width : 1601px)"></h:outputStylesheet>
                <h:outputStylesheet library="css" name="company/search/search_tablet.css" media="screen and (min-device-width : 768px) and (max-device-width : 1024px), screen and (max-width:1024px)"></h:outputStylesheet>
                <h:outputStylesheet library="css" name="company/search/search_smartphone.css" media="screen and (min-device-width : 320px) and (max-device-width : 767px), screen and (max-width:767px)"></h:outputStylesheet>
                <h:form id='totalFacesForm'>
                    <h:inputHidden id='facesTotalNumber' value='#{newCreateSearchBean.entityList.size()}'></h:inputHidden>
                </h:form> 

                <p:dialog id="candidateDetailDialog" widgetVar="candidateDetailDialog" resizable="false" modal="true" position="top">
                    <ccDetail:CandidateDetailPanel id="candidateDetailPanel" 
                                                   bean="#{newCreateSearchBean}"
                                                   candidate="#{newCreateSearchBean.chosenEntity.candidate}"
                                                   >
                    </ccDetail:CandidateDetailPanel>
                    <h:form>
                        <p:commandButton update=":bagPanel" styleClass="blueBackgroundStrong inlineBlock" actionListener="#{bagBean.addCandidate(newCreateSearchBean.chosenEntity)}" global="false" oncomplete="PF('candidateDetailDialog').hide();" value="#{messages.Select}" process="@this"></p:commandButton>                    
                    </h:form>
                </p:dialog>

                <ccFilter:KeywordsFilter id="keywordsFilter"
                                         bean="#{newCreateSearchBean}"
                                         />
                <ccFilter:PersonalFilter id="personalFilter"
                                         bean="#{newCreateSearchBean}"
                                         />                                    
                <ccFilter:ProfessionalFilter id="professionalFilter"
                                             bean="#{newCreateSearchBean}"
                                             />                                        
                <ccFilter:EducationalFilter id="educationalFilter"
                                            bean="#{newCreateSearchBean}"
                                            />
                <ccFilter:LanguageFilter id="languageFilter"
                                         bean="#{newCreateSearchBean}"
                                         />
                <ccFilter:RelocatingFilter id="relocatingFilter"
                                           bean="#{newCreateSearchBean}"
                                           />
                <ccFilter:InterestFilter id="interestFilter"
                                         bean="#{newCreateSearchBean}"
                                         />

                <h:form id="createSearchForm" styleClass="fullWidthContainer">
                    <p:growl id="searchGrowl"></p:growl>
                    <p:panel id="addFilterPanel" styleClass="marginBottom05em fullPanelMargin lightGrayBackgroundTitle fullWidthPanelTitlePadding noMargin noPaddingTitle  lightGrayBorder marginTop05em" header="Añadir filtro">
                        <p:panel  styleClass="noBorder noPadding noMargin" >
                            <p:commandButton style="margin-right:1%;" process="@this" value="#{messages.Keywords}" styleClass="blueBackgroundStrong" oncomplete="PF('keywordsFilterDialog').show();" update=":keywordsFilter:keywordsFilterForm:keywordsFilterPanel"></p:commandButton>
                            <p:commandButton style="margin-right:1%;" process="@this" value="#{messages.Personal}" styleClass="blueBackgroundStrong" oncomplete="PF('personalFilterDialog').show();" update=":personalFilter:personalFilterForm:personalFilterPanel"></p:commandButton>
                            <p:commandButton style="margin-right:1%;" value="#{messages.Professional}" styleClass="blueBackgroundStrong" oncomplete="PF('professionalFilterDialog').show()" update=":professionalFilter:professionalFilterForm:professionalFilterPanel" actionListener="#{newCreateSearchBean.reinitSearchProfessionalRequeriment()}" process="@this"/>
                            <p:commandButton style="margin-right:1%;" value="#{messages.Educational}" styleClass="blueBackgroundStrong" oncomplete="PF('educationalFilterDialog').show()" update=":educationalFilter:educationalFilterForm:educationalFilterPanel" actionListener="#{newCreateSearchBean.reinitSearchEducationalRequeriment()}" process="@this"/>
                            <p:commandButton style="margin-right:1%;" value="#{messages.Language}" styleClass="blueBackgroundStrong" oncomplete="PF('languageFilterDialog').show()" update=":languageFilter:languageFilterForm:languageFilterPanel" actionListener="#{newCreateSearchBean.reinitSearchLanguageRequeriment()}" process="@this"/>
                            <p:commandButton style="margin-right:1%;" value="#{messages.Relocating}" styleClass="blueBackgroundStrong" oncomplete="PF('relocatingFilterDialog').show()" update=":relocatingFilter:relocatingFilterForm:relocatingFilterPanel" actionListener="#{newCreateSearchBean.reinitSearchRelocatingRequeriment()}" process="@this"/>
                            <p:commandButton value="#{messages.Interest}" styleClass="blueBackgroundStrong" oncomplete="PF('interestFilterDialog').show()" update=":interestFilter:interestFilterForm:interestFilterPanel" actionListener="#{newCreateSearchBean.reinitSearchInterestRequeriment()}" process="@this"/>
                        </p:panel>
                    </p:panel>
                    <p:panel styleClass="fullPanelMargin mediumGrayBackgroundTitle fullWidthPanelTitlePadding noMargin noPaddingTitle  mediumGrayBorder" header="#{messages.ActualFilters}">
                        <p:panel id="searchPanel" styleClass="noBorder noPadding noMargin" >
                            <p:panel id="id1" styleClass="noBorder noPadding noMargin">
                                
                                <ccActualFilter:KeywordsActualFilter bean="#{newCreateSearchBean}"/>
                                <ccActualFilter:PersonalActualFilter bean="#{newCreateSearchBean}"/>
                                <ccActualFilter:ProfessionalActualFilterOr bean="#{newCreateSearchBean}"/>
                                <ccActualFilter:ProfessionalActualFilterAnd bean="#{newCreateSearchBean}"/>
                                <ccActualFilter:EducationalActualFilterOr bean="#{newCreateSearchBean}"/>
                                <ccActualFilter:EducationalActualFilterAnd bean="#{newCreateSearchBean}"/>
                                <ccActualFilter:LanguageActualFilterOr bean="#{newCreateSearchBean}"/>
                                <ccActualFilter:LanguageActualFilterAnd bean="#{newCreateSearchBean}"/>
                                <ccActualFilter:RelocatingActualFilterOr bean="#{newCreateSearchBean}"/>
                                <ccActualFilter:RelocatingActualFilterAnd bean="#{newCreateSearchBean}"/>
                                <ccActualFilter:InterestActualFilterOr bean="#{newCreateSearchBean}"/>
                                <ccActualFilter:InterestActualFilterAnd bean="#{newCreateSearchBean}"/>
                                
                            </p:panel>
                        </p:panel>
                    </p:panel>
                </h:form>
                <p:panel id='facesPanel'>
                    <div id="list">
                        <ui:repeat rendered="#{not empty newCreateSearchBean.entityList}" id="listRepeater1" var="candidate" value="#{newCreateSearchBean.scrollEntities}">
                            <div style="display:inline-block;width:23.50%;">
                                <h:form>
                                    <p:commandLink actionListener="#{newCreateSearchBean.setChosenEntityByIdEntity}" oncomplete="PF('candidateDetailDialog').show();" styleClass="imagenBusqueda" process="@this" update=":candidateDetailDialog" style="display:block;">  
                                        <h:graphicImage style="min-height: 135px;" rendered="#{candidate.bustBlackWhite!=null}" styleClass="width100" value="/candidateFiles/#{candidate.idCandidate.toString()}/images/#{candidate.bustBlackWhite}"></h:graphicImage>                 
                                        <f:param name="idEntity" value="#{candidate.idCandidate}"></f:param>
                                    </p:commandLink>
                                </h:form>
                            </div>
                        </ui:repeat>
                    </div>
                </p:panel>
                <h:form>
                    <p:remoteCommand process='@this' name="initFacesRemoteCommand" autoRun="true" async="true" rendered="#{empty newCreateSearchBean.entityList}" actionListener="#{newCreateSearchBean.initCandidates()}" update=":facesPanel :totalFacesForm :footer"></p:remoteCommand>
                </h:form>
                <p:panel id="footer" styleClass="noBorder">
                    <pe:waypoint rendered="#{not empty newCreateSearchBean.entityList}" id="waypoint" widgetVar="waypointWidget" offset="function(){return $.waypoints('viewportHeight') - $(this).outerHeight()+55}">
                        <pe:javascript event="reached" execute="prueba(ext);"/>
                    </pe:waypoint>
                </p:panel> 
            </ui:define>
        </ui:composition>
    </body>
</html>
